package com.yxw.bamboo.core.send.event.mysql;

import com.yxw.bamboo.core.send.event.EventArgs;
import com.yxw.bamboo.core.send.event.SendEvent;
import com.yxw.bamboo.core.send.event.SqlEventListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class DefaultAfterMySqlEventListenerImpl implements SqlEventListener
{
    @Autowired
    @Qualifier("mySqlDefaultAfterSendEvent")
    private List<SendEvent> afterEventList;

    @Override
    public void register(SendEvent sendEvent) {
        afterEventList.add(sendEvent);
    }

    @Override
    public void trigger(Object eventSource, EventArgs eventArgs) throws Exception {
        for (SendEvent sendEvent:this.afterEventList) {
            sendEvent.process(eventSource,eventArgs);
        }
    }

}
